package com.ciaojian.worker.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ciaojian.core.model.UserTag;
import com.ciaojian.core.util.Result;
import com.ciaojian.worker.service.UserTagServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author Atlakyn
 */
@Api(tags = "用户标签")
@RestController
@RequestMapping("/user/{userId}/tags")
public class UserTagController {
    @Resource
    private UserTagServiceImpl userTagService;

    @ApiOperation("获取用户标签")
    @GetMapping
    public Result getUserTags(@PathVariable Integer userId) {
        LambdaQueryWrapper<UserTag> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(UserTag::getUserId, userId);
        return Result.ok(userTagService.list(lambdaQueryWrapper));
    }

    @ApiOperation("添加/修改用户标签")
    @PostMapping
    public Result addUserTags(@RequestBody List<UserTag> userTagList) {
        userTagService.addUserTags(userTagList);
        return Result.ok();
    }
}